﻿IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_DUONG_KHAO_SAT_searchDuong]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[sproc_DUONG_KHAO_SAT_searchDuong]
GO
 
CREATE PROCEDURE [dbo].sproc_DUONG_KHAO_SAT_searchDuong
	@QUANID INT,
	@PHUONGID INT
AS
BEGIN
	SELECT
		dks.DUONG
		--dks.NGAY_KHOI_TAO,
		--dks.ACTIVE_FLAG
	FROM
		DUONG_KHAO_SAT dks
	WHERE dks.QUAN = @QUANID AND dks.PHUONG = @PHUONGID
	GROUP BY dks.DUONG
	
END
GO 

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_DUONG_KHAO_SAT_searchDoanDuong]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[sproc_DUONG_KHAO_SAT_searchDoanDuong]
GO
 
CREATE PROCEDURE [dbo].sproc_DUONG_KHAO_SAT_searchDoanDuong
	@QUANID INT,
	@PHUONGID INT
AS
BEGIN
	SELECT
		dks.DOAN_DUONG
	FROM
		DUONG_KHAO_SAT dks
	WHERE dks.QUAN = @QUANID AND dks.PHUONG = @PHUONGID
	GROUP BY dks.DOAN_DUONG
	
END


/* test */
--EXEC sproc_DUONG_KHAO_SAT_searchDuong 77,101